		<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <ext:ResourceManager ID="ResourceManagerProxy1" runat="server">
    </ext:ResourceManager>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ext:Viewport ID="ViewPort1" runat="server" Layout="fit">
        <Items>
            <ext:FormPanel ID="pnlAddCustomer" runat="server" Title="新增customer信息" Frame="true" ButtonAlign="Center">
                <Items>
										    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtId" runat="server" FieldLabel="ID" AllowBlank="False" BlankText="请输入ID！"   Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtName" runat="server" FieldLabel="Name"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtPassword" runat="server" FieldLabel="Password"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtUserType" runat="server" FieldLabel="UserType"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>
    <ext:Container runat="server" Layout="HBoxLayout" Height="28">
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
						<ext:TextField id="txtAddress" runat="server" FieldLabel="Address"  Padding="2" Flex="1"  /> 
                        </Items>
                    </ext:Container>

                </Items>
                <Buttons>
                    <ext:Button runat="server" Text="保存"  Icon="Accept">
                        <DirectEvents>
                            <Click Before="if(!#{pnlAddCustomer}.getForm().isValid()) return false;" OnEvent="btnAddCustomer_Click"
                                Success="#{pnlAddCustomer}.getForm().reset();parent.ShowMessage('操作成功','添加customer成功！',1);parent.RefreshCustomerData();parent.CloseAddCustomer(); "
                                 Failure="Ext.Msg.alert('操作失败', result.errorMessage);">
                                <EventMask ShowMask="true" Msg="数据保存中,请稍等....." />
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button runat="server" Text="取消" Icon="Decline">
                        <Listeners>
                            <Click Handler="parent.CloseAddCustomer();"></Click>
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </Items>
    </ext:Viewport>
</asp:Content>

	    protected void Page_Load(object sender, EventArgs e)
        {
            if (X.IsAjaxRequest)
                return;
 
        }

        protected void btnAddCustomer_Click(object sender, DirectEventArgs e)
        {
            try
            {
                Customer newCustomer = new Customer();

                
										   newCustomer.Id = this.txtId.Text.Trim();
   newCustomer.Name = this.txtName.Text.Trim();
   newCustomer.Password = this.txtPassword.Text.Trim();
   newCustomer.UserType = this.txtUserType.Text.Trim();
   newCustomer.Address = this.txtAddress.Text.Trim();



                Global.CurrentServiceContainer.CustomerServiceProxy.Insert(newCustomer);
 
                ResourceManager.AjaxSuccess = true;
 
            }
            catch (Exception ex)
            {
                ResourceManager.AjaxSuccess = false;
                ResourceManager.AjaxErrorMessage = "Error Message:" + ex.Message;
            }

        } 
			
